﻿using Newtonsoft.Json;

namespace Maple.Weixin.MP.Entities.JsonResult
{
    public class UploadMediaResult
    {
        public UploadMediaType type { get; set; }
        public string media_id { get; set; }
        public string created_at { get; set; }

        public static UploadMediaResult ParseJson(string json) {
            var obj = JsonConvert.DeserializeAnonymousType(json, new {type = "", media_id = "", created_at = ""});
            var result = new UploadMediaResult
                {
                    media_id = obj.media_id,
                    created_at = obj.created_at,
                    type = EnumExtensions.ConvertToEnum<UploadMediaType>(obj.type)
                };
            return result;
        }
    }
}
